const { Sequelize } = require("sequelize");

// 方法 3: 分别传递参数 (其它数据库)
const sequelize = new Sequelize(process.env.DATABASE_NAME, process.env.DATABASE_USER, process.env.DATABASE_PASS, {
    host: process.env.HOST,
    dialect: "mysql",/* 选择 'mysql' | 'mariadb' | 'postgres' | 'mssql' 其一 */
    logging: null
});

(async () => {
    try {
        await sequelize.authenticate();
        console.log('Connection has been established successfully.');
    } catch (error) {
        console.error('Unable to connect to the database:', error);
    }
})();

module.exports = sequelize;